using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using NWrapper.Config;
using NWrapper.Entities;

namespace NWrapper.Repositories
{
	/// <summary>
	/// Singleton instance of a repository that does nothing.
	/// </summary>
	public class NullRepository : IRepository
	{
		#region IRepository Members
		/// <summary>
		/// Initializes the repository; doesn't actually do anything.
		/// </summary>
		/// <param name="settings">The settings used for initialization.</param>
		public void Initialize(RepositorySettings settings)
		{
			//does nothing
		}

		#region Retrieve
		/// <summary>
		/// Does nothing.
		/// </summary>
		/// <typeparam name="T">Ignored.</typeparam>
		/// <returns>An empty collection.</returns>
		public ICollection<T> Retrieve<T>()
		{
			return new Collection<T>();
		}
		/// <summary>
		/// Does nothing.
		/// </summary>
		/// <typeparam name="T">Ignored.</typeparam>
		/// <param name="whereClause">Ignored.</param>
		/// <returns>An empty collection.</returns>
		public ICollection<T> Retrieve<T>(string whereClause)
		{
			return new Collection<T>();
		}
		/// <summary>
		/// Does nothing.
		/// </summary>
		/// <typeparam name="T">Ignored.</typeparam>
		/// <param name="whereClause">Ignored.</param>
		/// <param name="sortClause">Ignored.</param>
		/// <returns>An empty collection.</returns>
		public ICollection<T> Retrieve<T>(string whereClause, string sortClause)
		{
			return new Collection<T>();
		}
		/// <summary>
		/// Does nothing.
		/// </summary>
		/// <typeparam name="T">Ignored.</typeparam>
		/// <param name="whereClause">Ignored.</param>
		/// <param name="sortClause">Ignored.</param>
		/// <param name="startRowIndex">Ignored.</param>
		/// <param name="maximumRows">Ignored.</param>
		/// <returns>An empty collection.</returns>
		public ICollection<T> Retrieve<T>(string whereClause, string sortClause, int startRowIndex, int maximumRows)
		{
			return new Collection<T>();
		}
		#endregion

		#region RetrieveFirst
		/// <summary>
		/// Does nothing.
		/// </summary>
		/// <typeparam name="T">Ignored.</typeparam>
		/// <returns>Null.</returns>
		public T RetrieveFirst<T>()
		{
			return default(T);
		}
		/// <summary>
		/// Does nothing.
		/// </summary>
		/// <typeparam name="T">Ignored.</typeparam>
		/// <param name="whereClause">Ignored.</param>
		/// <returns>Null.</returns>
		public T RetrieveFirst<T>(string whereClause)
		{
			return default(T);
		}
		/// <summary>
		/// Does nothing.
		/// </summary>
		/// <typeparam name="T">Ignored.</typeparam>
		/// <param name="whereClause">Ignored.</param>
		/// <param name="sortClause">Ignored.</param>
		/// <returns>Null.</returns>
		public T RetrieveFirst<T>(string whereClause, string sortClause)
		{
			return default(T);
		}
		#endregion

		#region RetrievePage
		/// <summary>
		/// Does nothing.
		/// </summary>
		/// <typeparam name="T">Ignored.</typeparam>
		/// <param name="pageSize">Ignored.</param>
		/// <param name="pageIndex">Ignored.</param>
		/// <returns>An empty collection.</returns>
		public ICollection<T> RetrievePage<T>(int pageSize, int pageIndex)
		{
			//return an empty list
			return new Collection<T>();
		}
		/// <summary>
		/// Does nothing.
		/// </summary>
		/// <typeparam name="T">Ignored.</typeparam>
		/// <param name="sortClause">Ignored.</param>
		/// <param name="pageSize">Ignored.</param>
		/// <param name="pageIndex">Ignored.</param>
		/// <returns>An empty collection.</returns>
		public ICollection<T> RetrievePage<T>(string sortClause, int pageSize, int pageIndex)
		{
			//return an empty list
			return new Collection<T>();
		}
		/// <summary>
		/// Does nothing.
		/// </summary>
		/// <typeparam name="T">Ignored.</typeparam>
		/// <param name="whereClause">Ignored.</param>
		/// <param name="sortClause">Ignored.</param>
		/// <param name="pageSize">Ignored.</param>
		/// <param name="pageIndex">Ignored.</param>
		/// <returns>An empty collection.</returns>
		public ICollection<T> RetrievePage<T>(string whereClause, string sortClause, int pageSize, int pageIndex)
		{
			//return an empty list
			return new Collection<T>();
		}
		#endregion

		#region Save
		/// <summary>
		/// Does nothing.
		/// </summary>
		/// <typeparam name="T">Ignored.</typeparam>
		/// <param name="instance">Ignored.</param>
		public void Save<T>(T instance)
		{
			//does nothing
		}
		/// <summary>
		/// Does nothing.
		/// </summary>
		/// <typeparam name="T">Ignored.</typeparam>
		/// <param name="instance">Ignored.</param>
		/// <param name="includeChildren">Ignored.</param>
		public void Save<T>(T instance, bool includeChildren)
		{
			//does nothing
		}
		/// <summary>
		/// Does nothing.
		/// </summary>
		/// <typeparam name="T">Ignored.</typeparam>
		/// <param name="instances">Ignored.</param>
		public void Save<T>(IEnumerable<T> instances)
		{
			//does nothing
		}
		/// <summary>
		/// Does nothing.
		/// </summary>
		/// <typeparam name="T">Ignored.</typeparam>
		/// <param name="instances">Ignored.</param>
		/// <param name="includeChildren">Ignored.</param>
		public void Save<T>(IEnumerable<T> instances, bool includeChildren)
		{
			//does nothing
		}
		#endregion

		#region Delete
		/// <summary>
		/// Does nothing.
		/// </summary>
		/// <typeparam name="T">Ignored.</typeparam>
		/// <param name="instance">Ignored.</param>
		public void Delete<T>(T instance)
		{
			//does nothing
		}
		/// <summary>
		/// Does nothing.
		/// </summary>
		/// <typeparam name="T">Ignored.</typeparam>
		/// <param name="instances">Ignored.</param>
		public void Delete<T>(IEnumerable<T> instances)
		{
			//does nothing
		}
		/// <summary>
		/// Does nothing.
		/// </summary>
		/// <typeparam name="T">Ignored.</typeparam>
		/// <param name="whereClause">Ignored.</param>
		/// <returns>Zero.</returns>
		public int Delete<T>(string whereClause)
		{
			//does nothing
			return 0;
		}
		#endregion

		#region Insert
		/// <summary>
		/// Does nothing.
		/// </summary>
		/// <typeparam name="T">Ignored.</typeparam>
		/// <param name="instance">Ignored.</param>
		public void Insert<T>(T instance)
		{
			//does nothing
		}
		#endregion

		#region Resync
		/// <summary>
		/// Does nothing.
		/// </summary>
		/// <typeparam name="T">Ignored.</typeparam>
		/// <param name="obj">Ignored.</param>
		/// <returns><paramref name="obj"/>.</returns>
		public T Resync<T>(T obj)
		{
			return obj;
		}
		#endregion

		#region GetObjectCount
		/// <summary>
		/// Does nothing.
		/// </summary>
		/// <typeparam name="T">Ignored.</typeparam>
		/// <returns>Zero.</returns>
		public int GetObjectCount<T>()
		{
			return 0;
		}
		#endregion

		#endregion
	}
}
